package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

/*
 缓冲字符流，最常用的读写字符串的流
 */
public class BWDemo {
    public static void main(String[] args) throws IOException {
        //文件流
        FileOutputStream fos=new FileOutputStream("bw.txt");
        //转换流
        OutputStreamWriter osw=new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        //缓冲字符流 BufferedWriter  为了加快读写速度
        BufferedWriter bw=new BufferedWriter(osw);
        //写出
        bw.write("When we make contact boy "+"\n");
        bw.write("It's a chain reaction");
        System.out.println("Finished!");
        bw.close();

        //换行操作PrintWrite
//        PrintWriter pw=new PrintWriter("bw.txt");
//        pw.print("When we make contact boy ");
//        pw.println("It's a chain reaction");
//        pw.close();


        //是否可以用字节流进行？那字符流存在的意义是？
//        FileOutputStream fos=new FileOutputStream("bw.txt");
//        BufferedOutputStream bos=new BufferedOutputStream(fos);
//        bos.write("When we make contact boy".getBytes(StandardCharsets.UTF_8));
//        System.out.println("Finished!");
//        bos.close();

    }
}
